#include <iostream>
#include <list>

using std::cout;
using std::endl;
using std::list;

void test()
{
    /* list<int> number;//1、创建无参对象 */
    /* list<int> number(10, 5);//2、count个相同的value */
    //3、迭代器范围
    /* int arr[10] = {1, 3, 5, 7, 9, 8, 6, 4, 2, 10}; */
    /* list<int> number(arr, arr + 10);//左闭右开区间[,) */
    //4、拷贝或者移动构造函数
    //5、大括号
    list<int> number = {2, 4, 6, 8, 10, 9, 7, 5, 3, 1};

    //遍历
    /* for(size_t idx = 0; idx != number.size(); ++idx) */
    /* { */
    /*     cout << number[idx] << "  "; */
    /* } */
    /* cout << endl; */

    list<int>::iterator it;//未初始化的迭代器
    for(it = number.begin(); it != number.end(); ++it)
    {
        cout << *it << "  ";
    }
    cout << endl;

    list<int>::iterator it2 = number.begin();//初始化的迭代器
    for(; it2 != number.end(); ++it2)
    {
        cout << *it2 << "  ";
    }
    cout << endl;

    //for与auto结合
    for(auto &elem : number)
    {
        cout << elem << "  ";
    }
    cout << endl;
}

int main(int argc, char *argv[])
{
    test();
    return 0;
}

